package com.beiming.libra.controller;

import com.beiming.libra.domain.dto.requestdto.CaseUserDetailFormRequestDTO;
import com.beiming.libra.domain.dto.requestdto.CaseUserDetailListRequestDTO;
import com.beiming.libra.domain.dto.requestdto.CaseUserDetailRequestDTO;
import com.beiming.libra.domain.dto.requestdto.ProxyCaseUserDetailListRequestDTO;
import com.beiming.libra.helper.Result;
import com.beiming.libra.service.ArbitrationCaseUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @title 补正立案人员信息更新接口
 * @author zhengyu
 * @create_time 2018/6/11
 */
@RestController
@Api(value = "补正立案人员基础信息接口", tags = "补正立案人员基础信息接口")
@RequestMapping("/api/arbitrationCaseUserDetail")
public class ArbitrationCaseUserDetailController {

  @Resource
  private ArbitrationCaseUserService arbitrationCaseUserService;

  @PostMapping("/caseUser")
  @ApiOperation(value = "表单新增当事人", notes = "表单新增当事人")
  public Result addArbitrationCaseUserDetail(@RequestBody
      List<CaseUserDetailFormRequestDTO> caseUserDetailRequestDTOs) {
    arbitrationCaseUserService.addArbitrationCaseUser(caseUserDetailRequestDTOs);
    return Result.success();
  }

  @PostMapping("/caseUserList")
  @ApiOperation(value = "列表导入新增当事人", notes = "列表导入新增当事人")
  public Result addArbitrationCaseUserDetails(@RequestBody
      CaseUserDetailListRequestDTO caseUserDetailListRequestDTO) {
    arbitrationCaseUserService.addArbitrationCaseUsers(caseUserDetailListRequestDTO);
    return Result.success();
  }

  @PutMapping("")
  @ApiOperation(value = "修改当事人信息", notes = "修改当事人信息")
  public Result arbitrationCaseUserDetail(@RequestBody
      CaseUserDetailRequestDTO caseUserDetailRequestDTO) {
    arbitrationCaseUserService.updateArbitrationCaseUser(caseUserDetailRequestDTO);
    return Result.success();
  }

  @DeleteMapping("/{id}")
  @ApiOperation(value = "删除当事人信息", notes = "删除当事人信息")
  public Result removeCaseUserDetail(@ApiParam(value = "仲裁案件相关用户表id", required = true) @PathVariable("id") String id) {
    arbitrationCaseUserService.deleteArbitrationCaseUser(id);
    return Result.success();
  };

  @PostMapping("/proxyCaseUser")
  @ApiOperation(value = "表单新增代理人", notes = "表单新增代理人")
  public Result addArbitrationproxyCaseUserDetail(@RequestBody
      List<CaseUserDetailFormRequestDTO> caseUserDetailRequestDTOs) {
    arbitrationCaseUserService.addArbitrationCaseUser(caseUserDetailRequestDTOs);
    return Result.success();
  }

  @PostMapping("/proxyCaseUserList")
  @ApiOperation(value = "列表导入新增代理人", notes = "列表导入新增代理人")
  public Result addArbitrationproxyCaseUserDetails(@RequestBody
      ProxyCaseUserDetailListRequestDTO caseUserDetailListRequestDTO) {
    arbitrationCaseUserService.addArbitrationProxyCaseUsers(caseUserDetailListRequestDTO);
    return Result.success();
  }

}
